import marshal
a = [1, 2, 3, 4, 5, 6, 8, "111", "222", "333"]

# 1.写到内存变量
a_mal = marshal.dumps(a)
a_ret = marshal.loads(a_mal)
print(a_ret)

# 2.写到文件
with open("a.mal", "wb") as f:
    marshal.dump(a, f)

with open("a.mal", "rb") as f:
    a_ret = marshal.load(f)
    print(a_ret)

import os
mal_size = os.path.getsize("a.mal")
print("marshal size:", mal_size)
'marshal size: 55'